<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/include.inc.jsp"%>
<!DOCTYPE html>

<html>
<head>
<%@include file="/WEB-INF/views/layout/base.ref.jsp"%>
</head>
<body>
	<%@include file="/WEB-INF/views/login/home/toolbar.jsp"%>
	<div class="mtcontent">
		<div class="mtheader">
		<shiro:hasPermission name="sysUser:add">
			<a class="mtbtn one" href="#" onclick="hrefNew_OnClick('${ctx}/sysUser/edit?id=-1')"><span><i
					class="mtfa mt-add"></i>添加</span></a>
					</shiro:hasPermission>
            <shiro:hasPermission name="sysUser:del">
					 <a class="mtbtn two" href="#" onclick="bootstrapDel_OnClick('${ctx}/sysUser/del')"
				title="确定要删除吗?"> <i class="mtfa mt-del"></i><span>删除</span></a>
				</shiro:hasPermission>
		</div>
		<div class="mtbody">
			<form method="post" id="pagerForm" action="${ctx}/sysUser/list">
				<input type="hidden" name="ifSession" value="1" /> <input type="hidden" name="pageNum" value="1" /> <input
					type="hidden" name="pageSize" value="${vo.pageSize}" /> <input type="hidden" name="orderField"
					value="${param.orderField}" /> <input type="hidden" name="orderDirection" value="${param.orderDirection}" />
				<div class="mtrow">
					<div class="mtcolall">
						<label class="mtlabel-auto">用户名：</label> <input type="text" class="mtinput" name="arg" value="${vo.arg}" /> <label
							class="mtlabel-auto marginleft">姓名：</label> <input type="text" class="mtinput" name="arg1" value="${vo.arg1}" />
						<a class="mtbtn search marginleft" href="#" onclick="queryClick('pagerForm')"><i class="mtfa mt-search"></i><span>查询</span></a>
					</div>
				</div>
			</form>

			<div class="space-4"></div>
			<table id="grid">
			</table>
		</div>
	</div>
</body>
</html>

<script>
	$(function () {
	    $('#grid').bootstrapTable({
	        striped: true,                      //是否显示行间隔色
	        pagination: true,                   //是否显示分页（*）
	        sortable: true,                     //是否启用排序
	        clickToSelect: true,                //是否启用点击选中行
	        height: $(window).height() - 200,  //固定高度
	        columns: [
	        { title: '选择', field: 'check',checkbox:true, align: 'center', valign: 'middle'},
	        <shiro:hasPermission name="sysUser:edit">
	        {
	            title: '操作', field: 'id', checkbox: false, align: 'center', valign: 'middle', width: 80,
	            formatter: function (value, row, index) {
	                return '<a href="#" onclick="hrefNew_OnClick(\'${ctx}/sysUser/edit?id='+value +'\')"><i class="mtfa mt-pen mtblue mtpointer"></i></a>';
	            }
	        },
	        </shiro:hasPermission>
	        { title: '用户名', field: 'userName', align: 'center', valign: 'middle', sortable: true },
	        { title: '姓名', field: 'trueName', align: 'center', valign: 'middle', sortable: true },
	        { title: '员工编号', field: 'serils', align: 'center', valign: 'middle', sortable: true },
	        { title: '所属部门', field: 'departmentName', align: 'center', valign: 'middle', sortable: true },
	        { title: '顺序', field: 'showOrder', align: 'center', valign: 'middle', sortable: true },
	        {
	            title: '初始化密码', field: 'id', checkbox: false, align: 'center', valign: 'middle', width: 80,
	            formatter: function (value, row, index) {
	                return '<a href="#" onclick="csh_OnClick(\'${ctx}/sysUser/updatePwd\',\''+value +'\')">初始化密码</a>';
	            }
	        }
	        ],
	        data:${sysUserlist}
	    });
	});

	function csh_OnClick(url, id) {
		var datas = {
			ids : id
		};
		layer.confirm('您确定要初始化密码吗？', {
			icon : 3,
			title : '提示'
		}, function(index) {
			$.ajax({
				type : 'POST',
				url : url,
				data : datas,
				dataType : "json",
				cache : false,
				success : btnAjaxCallback,
				error : btnErrorAjaxCallback
			});
		});
		
	}
</script>